package com.fenshengou.xsm;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.rnfs.RNFSPackage;
import it.innove.BleManagerPackage;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import com.theweflex.react.WeChatPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.horcrux.svg.SvgPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import com.fenshengou.xsm.ToastPackage;
import com.fenshengou.xsm.BodyPlusPackage;

import java.util.Arrays;
import java.util.List;

import javax.annotation.Nullable;

import cc.bodyplus.sdk.ble.manger.BleConnectionManger;

public class MainApplication extends Application implements ReactApplication {

    private BPDfuListener mBPDfuListener;

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new RNFSPackage(),
                    new BleManagerPackage(),
                    new PickerPackage(),
                    new WeChatPackage(),
                    new RNFetchBlobPackage(),
                    new SvgPackage(),
                    new SplashScreenReactPackage(),
                    new VectorIconsPackage(),
                    new ToastPackage(),
                    new BodyPlusPackage()
            );
        }

        @Override
        protected String getJSMainModuleName() {
            return "index";
        }
    };

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mBPDfuListener = new BPDfuListener();
        BleConnectionManger.getInstance().init(this, mBPDfuListener);
    }
}
